package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.sun.org.apache.regexp.internal.RE;
import lombok.*;
import org.springframework.format.annotation.DateTimeFormat;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Getter
@Setter@ToString
public class TravelCommend extends BaseDomain {
    public static final Integer TYPE_WEEK =1;//每周推荐
    public static final Integer TYPE_MONTH =2;//每月推荐
    public static final Integer TYPE_STRATEGY=3;//攻略推荐

    private Travel travel;

    private String title;

    private String subTitle;

    private String coverUrl;
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date schedule;

    private Integer type;


    public String getTypeName(){
        String temp ="攻略推荐";
        if (TYPE_WEEK==type) {
            temp="每周推荐";
        }else{
            temp="每月推荐";
        }
        return  temp;
    }


    public Object getJson(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",id);
        map.put("title",title);
        map.put("travel",travel);
        map.put("subTitle",subTitle);
        map.put("coverUrl",coverUrl);
        map.put("schedule",new SimpleDateFormat("yyyy-MM-dd").format(schedule));
        map.put("type",type);

        return JSONUtil.toJSONString(map);
    }

}